package genetica.cromosomas.factorias;

import genetica.cromosomas.Cromosoma;
import genetica.cromosomas.CromosomaFuncion;
import genetica.cromosomas.evaluadores.evaluadorFuncionB;

import java.util.ArrayList;
import java.util.Random;

public class factoriaFuncionB extends FactoriaFuncion {

	public factoriaFuncionB( double precision){
		super(precision);
	}

	@Override
	public CromosomaFuncion crea() {
		Random r = new Random();
		ArrayList<Double>xmin = new ArrayList<Double>();
		ArrayList<Double>xmax = new ArrayList<Double>();
		xmin.add(-3.0);
		xmin.add(4.1);
		xmax.add(12.1);
		xmax.add(5.8);
		CromosomaFuncion c = new CromosomaFuncion(xmin,xmax,precision,r, new evaluadorFuncionB());
		return c;
	}

	@Override
	public CromosomaFuncion copia(Cromosoma original) {
		if (original instanceof CromosomaFuncion)
			return new CromosomaFuncion((CromosomaFuncion)original);
		else
			return null;
	}
	
	@Override
	public String toString(){
		return "f(x) = 21.5 + x·sen(4πx)+y·sen(20πy) : x ∈ [-3.0,12.1] | y ∈ [4.1,5.8]";
	}

}
